package com.dabai.iot.core.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dabai.common.mybatis.core.page.PageQuery;
import com.dabai.common.mybatis.core.page.TableDataInfo;
import com.dabai.common.web.core.BaseController;
import com.dabai.iot.core.dto.AlarmRecordQuery;
import com.dabai.iot.core.service.IAlarmRecordService;
import com.dabai.iot.core.vo.AlarmRecordVO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 告警记录管理
 *
 * @author kev1n
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/alarm/record")
public class AlarmRecordController extends BaseController {

    private final IAlarmRecordService alarmRecordService;

    /**
     * 告警记录分页
     */
    @GetMapping("/page")
    @Operation(summary = "告警记录分页", description = "传入对应查询参数")
    public TableDataInfo<AlarmRecordVO> page(PageQuery pageQuery, AlarmRecordQuery recordQuery) {
        IPage<AlarmRecordVO> pages = alarmRecordService.getRecordPage(pageQuery.build(), recordQuery);
        return TableDataInfo.build(pages);
    }

}
